import 'package:flutter/material.dart';

//import Page
import 'package:state_flutter/pages/Card/card.dart';
import 'package:state_flutter/pages/Login/login.dart';
import 'package:state_flutter/pages/Register/register.dart';

import 'package:state_flutter/components/Tabs/tabs.dart';

final routes = {
  "/": (context) => Tabs(),
  "/login": (context) => Login(),
  "/register": (context) => RegisterPage(),
  "/card": (context, {arguments}) => CardPage(arguments: arguments)
};

Route onGenerateRoute(RouteSettings settings){
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];

  if(pageContentBuilder != null){
    if(settings.arguments != null){
      //MaterialPageRoute跳转
      final Route route = MaterialPageRoute(
        builder: (context) =>
          pageContentBuilder(context, arguments: settings.arguments));
      return route;
    }else{
      final Route route = MaterialPageRoute(
        builder: (context)=>
          pageContentBuilder(context));
      return route;
    }
  }else{
    return null;
  }
}

